<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <title>amis demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="stylesheet" href="helper.css" />
    <link rel="stylesheet" href="sdk.css" />

    <link rel="stylesheet" href="iconfont.css" />
    <!-- 这是默认主题所需的，如果是其他主题则不需要 -->
    <!-- 从 1.1.0 开始 sdk.css 将不支持 IE 11，如果要支持 IE11 请引用这个 css，并把前面那个删了 -->
    <!-- <link rel="stylesheet" href="sdk-ie11.css" /> -->
    <!-- 不过 amis 开发团队几乎没测试过 IE 11 下的效果，所以可能有细节功能用不了，如果发现请报 issue -->
    <style>
        html,
        body,
        .app-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        .amis-scope .cxd-Layout-footer {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 0;
        }
        .amis-scope .cxd-Layout-content{padding-bottom:6rem;}
        .cxd-AppBcn{display:none}
        .cxd-Panel-heading{display:none}
        .amis-scope .cxd-Layout-headerBar{display:block;padding: 0.65rem;}
        .amis-scope .cxd-Layout-brandBar{display:none}
        .cxd-myClass, .myClass{fill:red}
        .cxd-AppFoldBtn{display:none}
        .app-wrapper { overflow: -moz-scrollbars-none; }
        .app-wrapper { -ms-overflow-style: none; }
        .app-wrapper::-webkit-scrollbar { width: 0 !important }

    </style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<script src="sdk.js"></script>
<script type="text/javascript">

        let amis = amisRequire('amis/embed');
        // 通过替换下面这个配置来生成不同页面
        let amisJSON = {
            "type": "page",
            "body":{
                "type":"form",
                "debug":true,
                "api":"http://localhost:8080/jeecg-boot/online/cgform/api/form/2c90e1277e421afc017e42bd2f340001?tabletype=1",
                "body":[
                    {
                        "name": "static",
                        "type": "static",
                        "label": "静态展示",
                        "value": "aaa"
                    },
                    {
                        "type": "input-sub-form",
                        "name": "form",
                        "label": "子Form",
                        "btnLabel": "设置子表单",
                        "form": {
                            "title": "配置子表单",
                            "body":  [
                                {
                                    "label": "选项",
                                    "type": "select",
                                    "name": "select",
                                    "menuTpl": "<div>${label} 值：${value}, 当前是否选中: ${checked}</div>",
                                    "source": {
                                        "method": "get",
                                        "url": "http://localhost:8080/jeecg-boot/online/cgreport/api/getColumnsAndData/1481185093420429314?_t=1642745175&job_name=10",
                                        "convertKeyToPath": false,
                                        adaptor: function (payload, response) {
                                            if( response.data.status == '0'){
                                                response.data.data  = {
                                                    'value':response.data.message
                                                };
                                            }
                                            console.log("payload",payload,response);
                                            return payload;
                                        }
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "name": "job_name",
                        "type": "input-text",
                        "label": "工作名称"
                    },
                    {
                        "name": "job_desc",
                        "type": "input-text",
                        "label": "工作描述"
                    },
                    {
                        "type": "input-file",
                        "name": "file_id",
                        "label": "文件",
                        "accept": "*",
                        "receiver": {
                            "method": "post",
                            "url": "http://localhost:8080/jeecg-boot/sys/common/upload",
                            "convertKeyToPath": false,
                            "data": {
                                "&": "$$"
                            },
                            adaptor: function (payload, response) {
                                if( response.data.status == '0'){
                                    response.data.data  = {
                                        'value':response.data.message
                                    };
                                }
                                console.log("payload",payload,response);
                                return payload;
                            }
                        }
                    }
                ]
            }
        }
        ;
        let amisScoped = amis.embed('#root', amisJSON,{
            "data":{
                "item":1,
                "item2":3
            }
        },{
            requestAdaptor:function(api){
                return {
                    ...api,
                    headers:{
                        'X-Access-Token':localStorage.getItem("token"),
                    }
                };
            },
            responseAdaptor:function(api, response, query, request){
                response.status = response.code;
                if( response.status == '200'){
                    response.status = '0';
                }
                response.data = response.result;
                response.result = null;
                response.msg = response.message;
                return response;
            }, theme: 'cxd'}
        );

</script>
</body>
</html>
